<meta charset="UTF-8">

<script type="text/javascript">
	$(function(){
		$("#admin_user").datagrid({
			idField: 'id',
			title: '管理员列表',
			fitColumns: true,
			width: '100%',
			striped: true,
			loadMsg: '数据正在加载...',
			rownumbers: true,
			singleSelect: true, 
			url: 'admin/list',
			sortName: 'id',
			singleSelect: true,
			sortOrder: 'asc',
			columns:[
				[
					{
						field: 'id',
						title: 'id',
						width: 100,
						align: 'center',
						sortable:true
					},{
						field: 'username',
						title: '用户名',
						width: 150,
						align: 'center'
					},{
						field: 'name',
						title: '姓名',
						width: 150,
						align: 'center'
					},{
						field: 'remark',
						title: '备注',
						width: 150,
						align: 'center'
					},{
						field: 'number',
						title: '借书数量',
						width: 150,
						align: 'center'
					}
				]
			],
			pagination: true ,
			pageSize: 10,
			pageList: [5, 10, 15, 20, 25, 50],
			dialog:{
				create:{
					title: '管理员添加',
					width: 430,
					height: 280,
					action: 'admin/save',
					href : 'admin/edit'
				},
				update:{
					title: '管理员修改',
					width: 430,
					height: 280,
					action: 'admin/save',
					href : 'admin/edit'
				},
				delete:{
					url: 'admin/delete'
				},
				reset:{
					url: 'admin/reset'
				}
			},
			toolbar: [$.crudgrid.buttons.create,'-',$.crudgrid.buttons.update,'-',$.crudgrid.buttons.delete,'-',$.crudgrid.buttons.reset,'-',$.crudgrid.buttons.reload,'-']
		});
		//查询
		$('#admin_searchbtn').click(function(){
			$('#admin_user').datagrid('load', serializeForm($('#admin_form').form()));
		});
		//清除查询
		$('#admin_clearbtn').click(function(){
			$('#admin_form').form('clear');
			$("#admin_user").datagrid('load', {});
		});
	});
</script>

<form class="layui-form" id = "admin_form" method="post">
	<div class="layui-input-inline">
		<input type="text" name="username" placeholder="请输入用户名" class="layui-input">
	</div>
	<div class="layui-input-inline">
		<input type="text" name="name" placeholder="请输入姓名" class="layui-input">
	</div>
 	<div class="layui-btn-group">
	  	<button type="button" id = "admin_searchbtn" class="layui-btn layui-btn-normal"><i class="layui-icon">&#xe615;</i>查询</button>
	  	<button type="button" id = "admin_clearbtn" class="layui-btn layui-btn-warm"><i class="layui-icon">&#xe640;</i>清空</button>
	</div>
</form>

<table id = "admin_user"></table>

